﻿@model IEnumerable<MvcMovie.Models.Movie>

@{
    ViewBag.Title = "Movie List";

    var classe = new MvcMovie.Models.Movie().GetType();
    var properties = classe.GetProperties();
    
}

<h2>My Movie List</h2>

@if (TempData["mensagem"] != null)
{
    <h1 style="color:Red;">@TempData["mensagem"]</h1>
    <br />
}

<table>
    <thead>
        <tr>
            @foreach (var property in properties)
            {
                if(!property.Name.Equals("Id"))
                {
                    <th>@property.Name</th>
                }
            }
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
        
            <tr>
                <td>@Html.DisplayFor(modelItem => item.Title)</td>
                <td>@Html.DisplayFor(modelItem => item.Genre)</td>
                <td>@Html.DisplayFor(modelItem => item.Price)</td>
                <td>@Html.DisplayFor(modelItem => item.ReleaseDate)</td>
                <td>@Html.ActionLink("Edition", "Edition", new { id = item.Id })</td>
                <td>@Html.ActionLink("Delete", "Delete", new {id = item.Id})</td>
            </tr>
        
        }
    </tbody>
    @Html.ActionLink("Add New Movie", "Create");
</table>